package com.fengwk.user.face.client;

import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.fengwk.user.face.client.hystrix.LoginClientHystrix;
import com.fengwk.user.face.constant.UserServerConstant;
import com.fengwk.user.face.model.LoginSession;

@FeignClient(
		name = UserServerConstant.FEIGN_CLIENT_NAME, 
		path = "/api/login",
		fallback = LoginClientHystrix.class)
public interface LoginClient {
	
	/**
	 * 通过通道和令牌获取登录会话
	 * 
	 * @param channel 通道
	 * @param token 令牌
	 * @return
	 */
	@PostMapping("/getLoginSessionByChannelAndToken")
	LoginSession getLoginSessionByChannelAndToken(
			@RequestParam(value = "channel", required = true) String channel,
			@RequestParam(value = "token", required = true) String token);
	
	/**
	 * 通过通道、身份、凭证登录
	 * 
	 * @param channel 通道
	 * @param identity 身份
	 * @param certification 凭证
	 * @return
	 */
	@PostMapping("/login")
	LoginSession login(
			@RequestParam(value = "channel", required = true) String channel,
			@RequestParam(value = "identity", required = true) String identity, 
			@RequestParam(value = "certification", required = true) String certification);
	
	/**
	 * 通过通道和令牌登出
	 * 
	 * @param channel 通道
	 * @param token 令牌
	 */
	@PostMapping("/logout")
	boolean logout(
			@RequestParam(value = "channel", required = true) String channel,
			@RequestParam(value = "token", required = true) String token);
	
}
